<template>
  <div class="all-box">
    <!-- 主页内容渲染 -->
    <div v-for="(item, index) in homedata" :key="index">
      <div :class="item.modeltype == 1 ? 'item-box' : 'rose-swipe'">
        <van-swipe
          :class="item.modeltype == 1 ? 'item-box' : 'rose-swipe'"
          :autoplay="2000"
          indicator-color="white"
          :style="{
            height: item.height + 'rem',
            display: item.modeltype == 1 ? 'none' : 'block',
          }"
        >
          <van-swipe-item v-for="(itm,index) in item.childrens[0].data" :key="index"
            >
            <router-link :to="itm.pathtype==2?'/detail/'+itm.url:'/goods/'+itm.url">
              <img :src="itm.src" alt="" style="width: 100%"/></router-link> 
          </van-swipe-item>
        </van-swipe>
        <div
          v-for="(itm, index) in item.childrens"
          :key="index"
          :style="{ display: item.modeltype == 2 ? 'none' : 'block' }"
          :class="item.modeltype == 1 ? 'item-box' : 'rose-swipe'"
        >
          <!-- <div v-for="itmm in itm.data" :key="itmm.url">
            <img
              :src="itmm.src"
              alt=""
              :style="{ width: itmm.width + 'rem' }"
            />
          </div> -->
          <router-link v-for="itmm in itm.data" :key="itmm.url" :to="itmm.url==''?'':itmm.pathtype==2?'/detail/'+itmm.url:'/goods/'+itmm.url">
            <img
              :src="itmm.src"
              alt=""
              :style="{ width: itmm.width + 'rem' }"
            />
          </router-link>
        </div>
      </div>
    </div>

    <!-- 主页底部 -->
    <div class="footer-box">
      <div class="footer-body">
        京ICP备13007738号 静公网安备11010502023922<br />
        www.roseonly.com.cn;诺誓（北京）商业股份有限公司
        <div class="div-cart">
          <div class="div-cart-pic zhizhao">营业执照</div>
          <div class="div-cart-pic fuben">食品证副本</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { homeData } from "../api/goods"
export default {
  data() {
    return {
      homedata: [],
      modeltype: 1,
      pathtype:'',
    };
  },
  created() {
    homeData().then((res) => {
      let homedata = res.data.data;
      this.homedata = homedata;
      // console.log(JSON.parse(JSON.stringify(this.homedata)));
    });
  },
};
</script>
<style src="../assets/css/home.css" scoped></style>
<style scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
}
</style>
